﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using AbpVueDemo.Demo.ClassDataManager.Dto;
using AbpVueDemo.JichuxinxiDome.CheliangDataManager.Dto;
using AbpVueDemo.JichuxinxinDemo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpVueDemo.JichuxinxiDome.CheliangDataManager
{
    public class CheDataService : AsyncCrudAppService<CheliangData,CheDataInputDto,int,PageCheDataRequestDto,CheDataCreateDto,CheDataUpdataDto>,ICheDataService
    {
        public CheDataService(
        IRepository<CheliangData, int> repository) : base(repository)
        {

        }
        /// <summary>
        /// 自定义分页条件查询, 需要重写父类的CreateFilteredQuery方法,让其进行自定义条件筛选
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns></returns>
        protected override IQueryable<CheliangData> CreateFilteredQuery(PageCheDataRequestDto input)
        {
            return base.CreateFilteredQuery(input)
                .WhereIf(!string.IsNullOrEmpty(input.c_brand), c => c.c_brand.Contains(input.c_brand))
                .WhereIf(!string.IsNullOrEmpty(input.c_plate), c => c.c_plate.Contains(input.c_plate))
                 .WhereIf(!string.IsNullOrEmpty(input.c_drivername), c => c.c_drivername.Contains(input.c_drivername))
                  .WhereIf(!string.IsNullOrEmpty(input.c_company), c => c.c_company.Contains(input.c_company));
        }
    }
}
